{{ $BASE_GOLANG_16_BUSTER := "golang:1.16.3-buster@sha256:9d64369fd3c633df71d7465d67d43f63bb31192193e671742fa1c26ebc3a6210" }}

project: deckhouse-web
configVersion: 1
---
# Base Images
{{ $_ := set . "Images" (.Files.Get "../../candi/image_versions.yml" | fromYaml) }}
  {{- range $k, $v := .Images }}
    {{ $baseImagePath := (printf "%s%s" $.Images.REGISTRY_PATH (trimSuffix "/" $v)) }}
    {{- if or (eq $.Env "development") (eq $.Env "module") }}
      {{ $baseImagePath = trimSuffix "/" $v | splitList "@" | first }}
    {{- end }}
    {{- if ne $k "REGISTRY_PATH" }}
      {{- $_ := set $.Images $k $baseImagePath }}
    {{- end }}
  {{- end }}

---
artifact: web-static
from: {{ .Images.BASE_JEKYLL }}
ansible:
  install:
    - shell: |
        apk add rsync
        gem update bundler
    - name: "Install Dependencies"
      shell: bundle install
      args:
        executable: /bin/bash
        chdir: /srv/jekyll-data/site/
  beforeSetup:
    - name: "Build static files"
      shell: |
        export JEKYLL_ENV=production
        mkdir -m 777 -p /app/_site/
        jekyll build -d /app/_site/ --config _config.yml --trace
      args:
        executable: /bin/bash
        chdir: /srv/jekyll-data/site/
git:
- add: /docs/site
  to: /srv/jekyll-data/site
  owner: jekyll
  group: jekyll
  excludePaths:
  - '**/*.sh'
  - LOCAL_DEV.md
  - werf*.yaml
  - docker-compose*.yml
  - .werf
  - .helm
  - backend
  - Makefile
  stageDependencies:
    install: ['Gemfile','Gemfile.lock']
    beforeSetup: '**/*'
---
image: web-backend
from: {{ $BASE_GOLANG_16_BUSTER }}
fromCacheVersion: 20210701
docker:
  WORKDIR: /app
ansible:
  install:
    - shell: apt update && apt install -yq git curl jq
    - shell: |
        go mod tidy
        go get github.com/go-delve/delve/cmd/dlv
      args:
        executable: /bin/sh
        chdir: /go/src/app
  setup:
    - shell: |
        go build -gcflags "all=-N -l" -v -o /app/server /go/src/app/cmd/v-router
      args:
        executable: /bin/sh
        chdir: /go/src/app
git:
  - url: https://github.com/flant/web-router.git
    tag: v1.0.14
    add: /
    to: /go/src/app
    stageDependencies:
      install: 'go.mod'
      setup: '**/*'
import:
  - artifact: web-static
    add: /app/_site
    to: /app/root
    before: setup
---
image: web-frontend
docker:
  WORKDIR: /app
from: {{ .Images.BASE_NGINX_ALPINE }}
ansible:
  setup:
  - name: "Copy nginx.conf"
    copy:
      content: |
        {{- .Files.Get ".werf/nginx.conf" | nindent 8 }}
      dest: /etc/nginx/nginx.conf
import:
- artifact: web-static
  add: /app/_site
  to: /app
  before: setup
  owner: nginx
  group: nginx
  excludePaths:
  - en/includes/
  - ru/includes/
